<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="java.util.ArrayList,edu.student.models.*, com.opensymphony.xwork2.ActionContext,java.util.Map,java.util.List" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="/static/jquery-1.3.1.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script language="javascript">
function doValidation() {
	var rollNo=document.getElementById("rollNo").value;
	var semester=document.getElementById("mysemester").value;
	var course=document.getElementById("mycourse").value;
	var grade=document.getElementById("grade").value;
	var result=document.getElementById("result").value;
	if (rollNo==""){
		alert("Roll No field is manadtaory.Please enter appropriately");
		return false;
	}
	if (mysemester==""){
		alert("Semester field is manadtaory.Please enter appropriately");
		return false;
	}
	if (mycourse==""){
		alert("Course field is manadtaory.Please enter appropriately");
		return false;
	}
	if (grade==""){
		alert("Grade field is manadtaory.Please enter appropriately");
		return false;
	}
	if (gradePt==""){
		alert("Grade Point field is manadtaory.Please enter appropriately");
		return false;
	}
	if (result==""){
		alert("Result field is manadtaory.Please enter appropriately");
		return false;
	}
	return true;
}
/* function populateLists(a){
	//document.getElementById("result").value="Pass";
	alert("in first func");
	alert(a);
	var b = a.value;
	alert(b);
	//var sub = document.userGrades.action + '?rollNo=' + b; // use whatever url you want to.   
	//alert(sub);  
	//document.userGrades.action = sub;
	document.userGrades.submit();
	mysemester.value=b;
} */
function fnGetSemester(a){
	var b = a.options[a.selectedIndex].value;
	var sub = document.userGrades.action + '?rollNo=' + b; // use whatever url you want to.   
	//alert(sub);  
	//document.myForm.action = sub;
	document.userGrades.submit();
	//alert("abt to go");
	//document.enrollPage.Enroll();
}
function populateLists(a){
	var b = a.options[a.selectedIndex].value;
	var sub = document.userGrades.action + '?mySemester=' + b; // use whatever url you want to.   
	//alert(sub);  
	//document.myForm.action = sub;
	document.userGrades.submit();
}
</script>
</head>
<body>
<h2>Release grades for user</h2>
<h3><s:property value="msg"/> </h3>
<s:form action="AdminUserGrades" name="userGrades">
<table id="text" align="center">
<tr>
<!-- takes student roll number as input -->
<td><s:select label="Select RollNo" headerKey="" headerValue="-none-" list="userList"  listvalue="userName" name="rollNo" id="rollNo" onChange="fnGetSemester(this)"></s:select></td>
<!-- displays the semester for which student has enrolled -->
<td><s:select label="Select Semester" headerKey="" headerValue="-none-" list="semesterList"  listvalue="semesterName" name="mySemester" id="mySemester" onChange="populateLists(this)"></s:select></td>
<!-- displays the courses for which student is enrolled -->
<td><s:select label="Select Course" headerKey="" headerValue="-none-" list="courseList" listkey="semesterName" listvalue="name" name="myCourse" id="myCourse"></s:select></td>
</tr>
<tr>
<td><s:textfield name="grade" label = "Grade"  size="20" id="grade"/></td>
</tr>
<tr>
<td><s:textfield name="gradePt" label = "Grade Point"  type="double" size="20" id="gradePt"/></td>
</tr>
<tr>
<td><s:textfield name="result" label = "Result"  size="20" id="result"/></td>
</tr>
<tr>
</tr>
</table>
<table id="text" align="center">
<tr>
<td><s:submit name="commandButton" value="Save" id = "mysubmit" style="height: 30px; width: 200px" onclick="return doValidation()">
</s:submit></td>
<td><s:submit name = "commandButton" value="View All Records" id = "mysubmit" style="height: 30px; width: 200px" onclick="return doValidation()">
</s:submit></td>
<td><s:form action="back" align="right" name = "Back">
<s:submit name = "commandButton" value="Back to Admin Home" id = "mysubmit" style="height: 30px; width: 200px">
</s:submit></s:form></td>
</tr>
</table>
</s:form>
</body>
</html>